﻿using System;

namespace MaoCaiJun.DataBase.Sys.Common
{
    public enum LogType { Warn, Info, Fatal, Error, Debug }
    public class Log
    {
        public delegate void LogWrite(LogType logType, object message, Exception exception);
        public static event LogWrite OnLogWrite;

        public static void Warn(object message)
        {
            if (OnLogWrite != null)
            {
                OnLogWrite(LogType.Warn, message, null);
            }

        }

        public static void Warn(object message, Exception exception)
        {
            if (OnLogWrite != null)
            {
                OnLogWrite(LogType.Warn, message, exception);
            }
        }
        public static void Info(object message)
        {
            if (OnLogWrite != null)
            {
                OnLogWrite(LogType.Info, message, null);
            }
        }

        public static void Info(object message, Exception exception)
        {
            if (OnLogWrite != null)
            {
                OnLogWrite(LogType.Info, message, exception);
            }
        }

        public static void Fatal(object message)
        {
            if (OnLogWrite != null)
            {
                OnLogWrite(LogType.Fatal, message, null);
            }
        }

        public static void Fatal(object message, Exception exception)
        {
            if (OnLogWrite != null)
            {
                OnLogWrite(LogType.Fatal, message, exception);
            }
        }

        public static void Error(object message)
        {
            if (OnLogWrite != null)
            {
                OnLogWrite(LogType.Error, message, null);
            }
        }

        public static void Error(object message, Exception exception)
        {
            if (OnLogWrite != null)
            {
                OnLogWrite(LogType.Error, message, exception);
            }
        }

        public static void Debug(object message)
        {
            if (OnLogWrite != null)
            {
                OnLogWrite(LogType.Debug, message, null);
            }
        }

        public static void Debug(object message, Exception exception)
        {
            if (OnLogWrite != null)
            {
                OnLogWrite(LogType.Debug, message, exception);
            }
        }
    }
}
